home *** CD-ROM | disk | FTP | other *** search
- /**
- GRAB Graph Layout and Browser System
-
- Copyright (c) 1986, 1988 Regents of the University of California
- Copyright (c) 1989, Tera Computer Company
- **/
-
- /**
- New and improved xgrab program. Now better than ever...
- **/
-
- #include "malloc.h"
- #include <stdio.h>
- #include <strings.h>
-
- #include "attribute.h"
- #include "digraph.h"
- #include "globals.h"
- #include "checkpoint.h"
- #include "interf.h"
-
- #define DEFAULT_NAME ""
-
- extern void gmain();
- extern VNO get_vno();
-
- extern double atof();
- extern int atoi();
- extern BOOL ReadIn();
-
- char cfileName[MAXSTR];
- BOOL cfile;
-
- /**
- main --
- process any options. Set up the window program.
- After things are set up we go into a select loop processing input
- from the mouse and keyboard.
- **/
- main(argc,argv)
- int argc;
- char *argv[];
- {
- /* initialize command line argument flag variables */
- InitCommandLineArgFlags();
- /* process the command line arguments */
- ProcessArgs(argc, argv);
- ginit(argc, argv);
- /* initialize global variables */
- InitGlobals();
- /* now make sure the asterisks are on the ON toggle menu items */
- AsteriskOnToggles();
-
- /* read in the graph and print it on the screen */
- if (ReadIn())
- {
- if (cfile)
- /* execute some commands initially */
- {
- read_commands(cfileName, TRUE);
- }
- else
- {
- DisplayReadGraph();
- }
- }
- else
- {
- DisplayReadGraph();
- }
-
- /* call the top level routine. */
- grun();
- exit(0);
- }
-
- InitCommandLineArgFlags()
- {
- int i;
-
- aspratio = 1.5;
- printLayoutTime = FALSE;
- stopInLayout = DONT_STOP;
- debug = FALSE;
- debug1 = FALSE;
- debug2 = FALSE;
- debug3 = FALSE;
- showbc = FALSE;
- cfile = FALSE;
- name = (char *) malloc(MAXSTR * (sizeof(char)));
- strcpy(name, DEFAULT_NAME);
-
- immedPercent = 1.0;
- for (i = 0; i < MAX_HEURISTIC; i++)
- heuristic[i] = FALSE;
- }
-
- #define ARGVAL() (*++(*argv) || (--argc && *++argv))
-
- ProcessArgs(argc, argv)
- int argc;
- char *argv[];
- {
- int readfile = 0;
-
- /* Argument Processing */
- for (argc--, argv++; argc > 0; argc--, argv++)
- {
- if (**argv == '-') /* A flag argument */
- {
- while (*++(*argv)) /* Process all flags in this arg */
- {
- switch (**argv)
- {
- case 'd':
- if (ARGVAL())
- {
- switch(atoi(*argv))
- {
- case 0:
- debug = TRUE;
- break;
- case 1:
- debug1 = TRUE;
- break;
- case 2:
- debug2 = TRUE;
- break;
- case 3:
- debug3 = TRUE;
- break;
- default:
- break;
- };
-
- goto nextarg;
- }
- break;
- case 's':
- showbc = TRUE;
- break;
- case 't':
- printLayoutTime = TRUE;
- break;
- case 'l':
- if (ARGVAL())
- {
- switch (atoi(*argv))
- {
- case 1:
- stopInLayout = STOP_AFTER_MAKEPROPER;
- break;
- case 2:
- stopInLayout = STOP_AFTER_MIN_CROSSING;
- break;
- default:
- break;
- }
-
- goto nextarg;
- }
- break;
- case 'a':
- if (ARGVAL())
- {
- aspratio = atof(*argv);
- goto nextarg;
- }
- break;
- case 'b':
- if (ARGVAL())
- {
- immedPercent = atof(*argv);
- goto nextarg;
- }
- break;
- case 'h':
- if (ARGVAL())
- {
- heuristic[atoi(*argv)] = TRUE;
- }
- break;
- case 'C':
- if (ARGVAL())
- {
- strncpy(cfileName, *argv, MAXSTR - 1);
- cfile = TRUE;
- goto nextarg;
- }
- break;
- default:
- fprintf(stderr, "Unknown flag: '%c';\n", **argv);
- fprintf(stderr, "Usage: xgrab [-a aspectRatio] [-C commandFileName] [-t] [-l1] [-l2] [-dn] [-s] [-b BC-Percentage] [-hn] [filename]\n");
- exit(1);
- }
- }
- }
- else /* Input file name */
- {
- if (readfile == 0)
- {
- strncpy(name, *argv, MAXSTR - 1);
- readfile++;
- }
- else
- {
- fprintf(stderr,
- "Duplicate input filenames: keeping %s, ignoring %s\n",
- name, *argv);
- }
- }
-
- nextarg: continue;
- }
- }
-
- /**
- InitGlobals --
- Inititalize all the global variables that need initializing.
- **/
- InitGlobals()
- {
- currMode = IN_BROWSE_MODE;
- zoomGradient = 0.75;
- panGradient = 0.05;
- Text_Flag = TRUE;
- printArrow = TRUE;
- printEdgeLabel = FALSE;
- inChangeTextMode = FALSE;
- inChangeEdgeLabelMode = FALSE;
- printNodeLabel = FALSE;
- markDummyNodes = FALSE;
- graphChanged = FALSE;
- ckpt_done = TRUE;
- changeOutEdges = FALSE;
- changeInEdges = FALSE;
- landscapePSFile = FALSE;
- straightenEdges = FALSE;
- ignoreHidden = TRUE;
- num_ckpts = 0;
- curr_ckpt = -1;
- ckpts = NULL;
- }
-